#pragma once

using namespace std;

#include <C2DImage.h>
#include <string.h>
#include <stdio.h>
#include <string>
#include <iostream>
//#include <CParticles.h>
#include <perlin.h>
#include <CMatrix.h>
#include <CGalaxyParams.h>
#include <CGalaxyComponent.h>
#include <CGalaxyComponentBulge.h>
#include <CGalaxyComponentStars.h>
#include <CGalaxyComponentDust.h>
#include <CGalaxyComponentDisk.h>
#include <CRenderingParams.h>
#include <CComponentParams.h>

class CGalaxy {

 public:

  CGalaxyParams params;

  CMatrix rotation; // Rotation matrix
  

  float PerlinScale; // general perlin noise scale


  vector<CGraph*> spectra;

  static const int SPECTRUM_BULGE = 0;
  static const int SPECTRUM_DISK = 1;
  static const int SPECTRUM_STARS = 2;

  // image 

  vector<CGalaxyComponent*> components;

  bool parametersInitialized;
  float average;
  float count;

  // Methods
  CGalaxy();
  void RandomOrientation();


  void InitializeFromFile(string f, CRenderingParams& RP);
  

  void setupComponentWavelength(double wavelength);

  void RandomParameters();

  void RandomizeSpectra();

  float getArm(float rad, CVector p, float disp);
  float getTheta(const CVector& p);
  float getIntensity(float AA, const float radius, const CVector& p);
  float getWinding(const float& rad);
  float findDifference(float t1, float t2);
 
  float calculateArmValue(float rad, CVector& P, float armStrength);

  void loadSpectra(vector<CGraph*>& sp);


  

};
